﻿package mortal.game.view.forging.view
{
    import Message.Public.*;
    import baseEngine.modifiers.*;
    import com.gengine.utils.*;
    import com.mui.controls.*;
    import com.mui.core.*;
    import com.mui.utils.*;
    import extend.language.*;
    import flash.events.*;
    import frEngine.*;
    import frEngine.event.*;
    import mortal.common.global.*;
    import mortal.component.gconst.*;
    import mortal.component.window.*;
    import mortal.component.windowTip.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.manager.window3d.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.scene3D.model.player.*;
    import mortal.game.scene3D.model.pools.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.common.guide.data.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.common.util.*;
    import mortal.game.view.forging.*;
    import mortal.game.view.forging.data.*;
    import mortal.game.view.guide.*;
    import mortal.game.view.palyer.*;
    import mortal.mvc.core.*;

    public class EquipTransformPanel extends ForgingPanelBase
    {
        private var _fromEquipCombat:BitmapNumberText;
        private var _toEquipCombat:BitmapNumberText;
        private var _reviewCombat:BitmapNumberText;
        private var _combatUpValue:GTextFiled;
        private var _upArrow:GBitmap;
        private var _selBagText:GTextFiled;
        private var _transformBtn:GButton;
        private var _upFee:GTextFiled;
        private var _reviewText1:GTextFiled;
        private var _reviewText2:GTextFiled;
        private var _reviewText3:GTextFiled;
        private var _explainText:GTextFiled;
        private var _transferLeftArrow:GImageBitmap;
        private var _transferRightArrow:GImageBitmap;
        private var _targetEquip:PlayerEquipItem;
        private var _reviewEquip:PlayerEquipItem;
        private var _backPackPanel:BackPackItemWin;
        private var _transFromEquip:PlayerEquipItem;
        private var _transToEquip:PlayerEquipItem;
        private var _isLeftToRight:Boolean;
        private var _gemHoleArr:Array;
        private var _addEquip:PlayerEquipItem;
        private var _effectPlayer:EffectPlayer;

        public function EquipTransformPanel(param1:Window = null)
        {
            this._gemHoleArr = [];
            super(param1);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.createChildren();
            return;
        }// end function

        private function onResLoadCompl(param1 = null) : void
        {
            if (isDisposed)
            {
                return;
            }
            this.createChildren();
            return;
        }// end function

        override protected function createChildren() : void
        {
            super.createChildren();
            this._backPackPanel = UICompomentPool.getUICompoment(BackPackItemWin);
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.EquipTransferPart1, 47 - 43, 47 - 47, this));
            this.pushUIToDisposeVec(UIFactory.bg(71 - 16, 12, 114, 27, this, ImagesConst.CombatTextBg));
            this.pushUIToDisposeVec(UIFactory.bg(324, 12, 114, 27, this, ImagesConst.CombatTextBg));
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.Forging_EquipTransferPart2, 95, 249, this));
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.Forging_Text_EquipCombat, 79 - 16, 17, this));
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.Forging_Text_EquipCombat, 324 + 8, 17, this));
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.Forging_CurrEquipText, 106 - 13, 106, this));
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.Forging_TargetEquipText, 354 + 10, 106, this));
            this._transferRightArrow = UIFactory.gImageBitmap(ImagesConst.Forging_TransferArrow, 294 - 93, 125 - 2, this);
            this._transferLeftArrow = UIFactory.gImageBitmap(ImagesConst.Forging_TransferArrow, 294, 124, this);
            this._transferLeftArrow.scaleX = -1;
            this._transferLeftArrow.visible = false;
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.Forging_CenterRectangle, 201, 111 - 3, this));
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(41130), 221, 118 - 4, 63, 20, this, GlobalStyle.textFormatLv));
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(41131), 221, 134 - 4, 63, 20, this, GlobalStyle.textFormatLv));
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.Forging_Arrow_Down, 202 - 7, 142, this));
            this.pushUIToDisposeVec(UIFactory.bg(177, 228, 158, 23, this, ImagesConst.RegionTitleBg));
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.Forging_Text_EquipCombat, 200, 231, this));
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.Forging_MoveReviewText, 232 - 4, 282 - 10, this));
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(41132), 187, 409 + 3, 88, 20, this, GlobalStyle.textFormatHuang));
            this.pushUIToDisposeVec(UIFactory.gBitmap(ImagesConst.Jinbi_bind, 304, 409 + 3, this));
            this._reviewText1 = UIFactory.gTextField(Language.getString(41133), 131 - 16, 15, 55, 20, this);
            this._reviewText2 = UIFactory.gTextField(Language.getString(41133), 376 + 8, 15, 55, 20, this);
            this._reviewText3 = UIFactory.gTextField(Language.getString(41133), 252, 229, 55, 20, this);
            this._upArrow = UIFactory.gBitmap(ImagesConst.upgradeArrow, 302, 232, this);
            this._upArrow.visible = false;
            this._combatUpValue = UIFactory.gTextField("", 313, 229, 50, 20, this, GlobalStyle.textFormatLv);
            this._selBagText = UIFactory.gTextField("", 429, 40, 60, 20, this);
            this._selBagText.htmlText = HTMLUtil.addLink(Language.getString(41134), GlobalStyle.colorLv);
            this._selBagText.configEventListener(TextEvent.LINK, this.onTextClick);
            this._selBagText.configEventListener(MouseEvent.MOUSE_OVER, this.onOverHandler);
            this._selBagText.configEventListener(MouseEvent.MOUSE_OUT, this.onOutHandler);
            this._explainText = UIFactory.gTextField("", 131 + 299, 409 + 3, 60, 20, this);
            this._explainText.htmlText = HTMLUtil.addLink(Language.getString(41135), GlobalStyle.colorLv);
            this._explainText.configEventListener(MouseEvent.CLICK, this.onLinkClickHandler);
            this._explainText.configEventListener(MouseEvent.MOUSE_OVER, this.onOverHandler);
            this._explainText.configEventListener(MouseEvent.MOUSE_OUT, this.onOutHandler);
            this._fromEquipCombat = UIFactory.bitmapNumberText(131 - 16, 18, "FightInfoNum.png", 12, 15, -1, this);
            this._toEquipCombat = UIFactory.bitmapNumberText(376 + 8, 18, "FightInfoNum.png", 12, 15, -1, this);
            this._reviewCombat = UIFactory.bitmapNumberText(253, 232, "FightInfoNum.png", 12, 15, -1, this);
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.Forging_TransferBtnLine, 91 + 14 - 5, 374 - 7, this));
            var _loc_1:* = UIFactory.gImageBitmap(ImagesConst.Forging_TransferBtnLine, 302 + 100 - 5, 374 - 6, this);
            this.pushUIToDisposeVec(_loc_1);
            _loc_1.scaleX = -1;
            this._transformBtn = UIFactory.gButton(Language.getString(41136), 212 - 5, 363, 82, 28, this, "BrownBtn");
            this._transformBtn.configEventListener(MouseEvent.CLICK, this.onTransformHandler);
            this._transformBtn.name = "Equip_TranstormBtn";
            this._transformBtn.toolTipData = Language.getString(41137);
            this.isTransAvailabel = false;
            this._upFee = UIFactory.gTextField("", 272, 409 + 3, 33, 20, this, GlobalStyle.textFormatHuang);
            _currOperEquip = UICompomentPool.getUICompoment(PlayerEquipItem);
            _currOperEquip.setItemStyle(ItemStyleConst.Big, "", 0, 0);
            _currOperEquip.x = 96 - 13;
            _currOperEquip.y = 97;
            this.addChild(_currOperEquip);
            _currOperEquip.configEventListener(MouseEvent.CLICK, this.onEquipClickHandler);
            this._targetEquip = UICompomentPool.getUICompoment(PlayerEquipItem);
            this._targetEquip.setItemStyle(ItemStyleConst.Big, "", 0, 0);
            this._targetEquip.x = 343 + 10;
            this._targetEquip.y = 97;
            this.addChild(this._targetEquip);
            this._targetEquip.configEventListener(MouseEvent.CLICK, this.onTargetEquipClickHandler);
            this._reviewEquip = UICompomentPool.getUICompoment(PlayerEquipItem);
            this._reviewEquip.setItemStyle(ItemStyleConst.Big, "", 0, 0);
            this._reviewEquip.x = 221 - 4;
            this._reviewEquip.y = 274 - 10;
            this.addChild(this._reviewEquip);
            Dispatcher.addEventListener(EventName.AddTargetEquip, this.addTargetEquip);
            NetDispatcher.addCmdListener(ServerCommand.EquipTransferInfoUpdate, this.onEquipTransferSucc);
            return;
        }// end function

        override public function updateUI() : void
        {
            return;
        }// end function

        override public function addForgingEquip(param1:PlayerEquipItem) : void
        {
            this._addEquip = param1;
            if (param1 && param1.itemData && _isCreateChildren)
            {
                this.clearUI();
                super.addForgingEquip(param1);
                _currOperEquip.updateStrengLevel();
                this.updateCombat(0);
                this.showBackPackPanel();
            }
            return;
        }// end function

        public function addTargetEquip(event:DataEvent) : void
        {
            var _loc_2:* = event.data as ItemData;
            if (_loc_2)
            {
                if (this._targetEquip.itemData && this._targetEquip.itemData.uid == _loc_2.uid)
                {
                    return;
                }
                this._targetEquip.itemData = _loc_2;
                this._targetEquip.updateStrengLevel();
                if (this.isLeftToRight())
                {
                    this._isLeftToRight = true;
                    this._transFromEquip = _currOperEquip;
                    this._transToEquip = this._targetEquip;
                    this._transferLeftArrow.visible = false;
                    this._transferRightArrow.visible = true;
                }
                else
                {
                    this._isLeftToRight = false;
                    this._transFromEquip = this._targetEquip;
                    this._transToEquip = _currOperEquip;
                    this._transferLeftArrow.visible = true;
                    this._transferRightArrow.visible = false;
                }
                this.updateCombat(1);
                this.updateReviewEquip();
                this.updateReviewCombat();
                this.updateUpFee();
                this.isTransAvailabel = true;
                this._backPackPanel.hide();
            }
            return;
        }// end function

        public function updateReviewEquip() : void
        {
            if (_currOperEquip.itemData && this._targetEquip.itemData)
            {
                this._reviewEquip.itemData = this.getReviewData();
                this._reviewEquip.updateStrengLevel();
            }
            return;
        }// end function

        private function getReviewData() : ItemData
        {
            var _loc_3:ItemData = null;
            var _loc_4:ItemData = null;
            var _loc_5:ItemData = null;
            var _loc_8:int = 0;
            var _loc_9:int = 0;
            var _loc_10:int = 0;
            var _loc_11:Array = null;
            var _loc_12:int = 0;
            var _loc_1:* = _currOperEquip.itemData;
            var _loc_2:* = this._targetEquip.itemData;
            if (this._isLeftToRight)
            {
                _loc_3 = _loc_1;
                _loc_4 = _loc_2;
            }
            else
            {
                _loc_3 = _loc_2;
                _loc_4 = _loc_1;
            }
            _loc_5 = new ItemData(_loc_4.itemCode, true);
            _loc_5.extInfo = _loc_4.extInfo.clone();
            _loc_5.itemInfo.bind = EBind._EBindYes;
            _loc_5.extInfo.bd = EBind._EBindYes;
            _loc_5.extInfo.strengthen = _loc_3.extInfo.strengthen;
            _loc_5.extInfo.currentStrengthen = _loc_3.extInfo.currentStrengthen;
            if (EquipmentUtil.isCanRefresh(_loc_3) && EquipmentUtil.isRefreshed(_loc_3) && EquipmentUtil.isCanRefresh(_loc_4))
            {
                _loc_8 = 1;
                while (_loc_8 <= 6)
                {
                    
                    _loc_5.extInfo["addition" + _loc_8] = _loc_3.extInfo["addition" + _loc_8];
                    _loc_5.extInfo["addStar" + _loc_8] = _loc_3.extInfo["addStar" + _loc_8];
                    _loc_8++;
                }
                _loc_5.extInfo.refresh_lock = "";
                _loc_5.extInfo.refresh_count = 0;
                if (_loc_5.extInfo.refresh_refDict)
                {
                    _loc_5.extInfo.refresh_refDict.length = 0;
                }
            }
            var _loc_6:* = EquipmentUtil.getGemHoleNum(_loc_4);
            var _loc_7:* = EquipmentUtil.getGemHoleNum(_loc_5);
            _loc_5.extInfo.hole_num = _loc_7;
            if (_loc_6 < _loc_7)
            {
                _loc_9 = _loc_7 - _loc_6;
                _loc_8 = 1;
                while (_loc_8 <= 8)
                {
                    
                    if (_loc_5.extInfo["h" + _loc_8] == null)
                    {
                        _loc_5.extInfo["h" + _loc_8] = "0";
                        _loc_9 = _loc_9 - 1;
                    }
                    if (_loc_9 == 0)
                    {
                        break;
                    }
                    _loc_8++;
                }
            }
            if (EquipmentUtil.isCanEmbed(_loc_5) && EquipmentUtil.isEmbedAvailable(_loc_5))
            {
                _loc_10 = 1;
                _loc_11 = [];
                _loc_8 = 1;
                while (_loc_8 <= 8)
                {
                    
                    if (_loc_5.extInfo["h" + _loc_8] == "0")
                    {
                        _loc_12 = _loc_10;
                        while (_loc_12 <= 8)
                        {
                            
                            if (_loc_3.extInfo["h" + _loc_12] != null && _loc_3.extInfo["h" + _loc_12] != "0")
                            {
                                _loc_5.extInfo["h" + _loc_8] = _loc_3.extInfo["h" + _loc_12];
                                _loc_11.push(_loc_12);
                                _loc_10 = (_loc_12 + 1) > 8 ? (8) : ((_loc_12 + 1));
                                break;
                            }
                            _loc_12++;
                        }
                    }
                    _loc_8++;
                }
            }
            return _loc_5;
        }// end function

        private function isLeftToRight() : Boolean
        {
            var _loc_5:Boolean = false;
            var _loc_1:* = _currOperEquip.itemData.extInfo.strengthen;
            var _loc_2:* = this._targetEquip.itemData.extInfo.strengthen;
            var _loc_3:* = _currOperEquip.itemData.extInfo.currentStrengthen;
            var _loc_4:* = this._targetEquip.itemData.extInfo.currentStrengthen;
            if (_loc_1 >= _loc_2)
            {
                _loc_5 = true;
                if (_loc_1 == _loc_2)
                {
                    if (_loc_3 >= _loc_4)
                    {
                        _loc_5 = true;
                    }
                    else
                    {
                        _loc_5 = false;
                    }
                }
            }
            else
            {
                _loc_5 = false;
            }
            return _loc_5;
        }// end function

        private function updateCombat(param1:int) : void
        {
            switch(param1)
            {
                case 0:
                {
                    this._fromEquipCombat.text = _currOperEquip.itemData.extInfo.combat + "";
                    if (this._reviewText1.visible)
                    {
                        this._reviewText1.visible = false;
                    }
                    break;
                }
                case 1:
                {
                    this._toEquipCombat.text = this._targetEquip.itemData.extInfo.combat + "";
                    if (this._reviewText2.visible)
                    {
                        this._reviewText2.visible = false;
                    }
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        private function updateCombatAfterTransfer() : void
        {
            if (this._transFromEquip.itemData == _currOperEquip.itemData)
            {
                this._fromEquipCombat.text = this._transFromEquip.itemData.extInfo.combat + "";
            }
            else
            {
                this._toEquipCombat.text = this._transFromEquip.itemData.extInfo.combat + "";
            }
            return;
        }// end function

        private function updateReviewCombat() : void
        {
            var _loc_1:ItemData = null;
            var _loc_2:int = 0;
            if (this._reviewEquip.itemData)
            {
                if (this._isLeftToRight)
                {
                    _loc_1 = this._targetEquip.itemData;
                }
                else
                {
                    _loc_1 = _currOperEquip.itemData;
                }
                this._reviewEquip.itemData.extInfo.combat = EquipmentUtil.getEquipCombat(this._reviewEquip.itemData);
                this._reviewCombat.text = this._reviewEquip.itemData.extInfo.combat + "";
                _loc_2 = this._reviewEquip.itemData.extInfo.combat - _currOperEquip.itemData.extInfo.combat;
                this._combatUpValue.text = Math.abs(_loc_2) + "";
                if (_loc_2 >= 0)
                {
                    this._upArrow.bitmapData = GlobalClass.getBitmapData(ImagesConst.upgradeArrow);
                }
                else
                {
                    this._upArrow.bitmapData = GlobalClass.getBitmapData(ImagesConst.downArrow);
                }
            }
            if (this._reviewText3.visible)
            {
                this._reviewText3.visible = false;
            }
            if (!this._upArrow.visible)
            {
                this._upArrow.visible = true;
            }
            return;
        }// end function

        private function onEquipTransferSucc(param1:Object) : void
        {
            if (AutoGuideCache.isGuidingEquipTransform)
            {
                AutoGuideCache.isGuidingEquipTransform = false;
            }
            this.playTransferEffect();
            GameController.forging.view.hide();
            return;
        }// end function

        override public function updateForgingInfo() : void
        {
            var _loc_1:GuideUseItemData = null;
            this._reviewEquip.itemData = this._transToEquip.itemData;
            this._reviewEquip.updateStrengLevel();
            this.onTransferSuccClear();
            this.updateCombatAfterTransfer();
            this._transFromEquip.updateStrengLevel();
            if (this._isLeftToRight)
            {
                if (this._reviewEquip.itemData.extInfo.combat > _currOperEquip.itemData.extInfo.combat)
                {
                    _loc_1 = new GuideUseItemData();
                    _loc_1.itemData = this._reviewEquip.itemData;
                    _loc_1.isCountdown = false;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.AutoGuideShowBackPackItem, _loc_1));
                }
            }
            return;
        }// end function

        private function updateUpFee() : void
        {
            var _loc_1:int = 0;
            var _loc_2:int = 0;
            var _loc_3:int = 0;
            var _loc_4:int = 0;
            if (_currOperEquip.itemData && this._targetEquip.itemData)
            {
                _loc_1 = this._transFromEquip.itemData.itemInfo.level;
                _loc_2 = this._transToEquip.itemData.itemInfo.level;
                _loc_3 = _loc_1 < _loc_2 ? (_loc_2) : (_loc_1);
                _loc_4 = EquipAdvanceConfig.instance.getConsumeMoneyByLevel(_loc_3);
                this._upFee.text = _loc_4 + "";
                if (Cache.instance.role.money.coin + Cache.instance.role.money.coinBind < _loc_4)
                {
                    this._upFee.textColor = GlobalStyle.colorHongUint;
                }
                else
                {
                    this._upFee.textColor = GlobalStyle.colorHuangUint;
                }
            }
            return;
        }// end function

        override public function updateMoneyState() : void
        {
            this.updateUpFee();
            return;
        }// end function

        private function onTextClick(event:TextEvent) : void
        {
            this.showBackPackPanel();
            return;
        }// end function

        private function onOverHandler(event:MouseEvent) : void
        {
            CursorManager.showCursor(CursorManager.BUTTON);
            return;
        }// end function

        private function onOutHandler(event:MouseEvent) : void
        {
            CursorManager.hideFromButton();
            return;
        }// end function

        private function onLinkClickHandler(event:MouseEvent) : void
        {
            var _loc_2:* = new WindowTipData();
            _loc_2.type = WindowTipType.DECOMPOSE_EXPLAIN;
            _loc_2.tip = Language.getString(40100);
            _loc_2.title = Language.getString(41135);
            _loc_2.tipW = 331;
            _loc_2.tipH = 112;
            WindowTipManager.showTip(_loc_2);
            return;
        }// end function

        private function showBackPackPanel() : void
        {
            var _loc_1:int = 0;
            var _loc_2:int = 0;
            if (this._backPackPanel.isHide)
            {
                _loc_1 = _window.x + 505;
                _loc_2 = _window.y + 60;
                this._backPackPanel.show(_loc_1, _loc_2);
            }
            this._backPackPanel.data = this.getAvailableData();
            return;
        }// end function

        private function getAvailableData() : Array
        {
            var _loc_2:ItemData = null;
            var _loc_3:int = 0;
            var _loc_4:int = 0;
            var _loc_5:int = 0;
            var _loc_6:int = 0;
            var _loc_7:int = 0;
            var _loc_8:Array = null;
            var _loc_9:Array = null;
            var _loc_10:ItemData = null;
            var _loc_11:TransferPackData = null;
            var _loc_12:TransferPackData = null;
            var _loc_1:Array = [];
            if (_currOperEquip.itemData)
            {
                _loc_2 = _currOperEquip.itemData;
                _loc_3 = Cache.instance.role.entityInfo.level;
                _loc_4 = _currOperEquip.itemData.itemInfo.type;
                _loc_5 = _currOperEquip.itemData.itemInfo.color;
                _loc_6 = _currOperEquip.itemData.itemInfo.career;
                _loc_7 = _currOperEquip.itemData.itemInfo.level;
                _loc_8 = Cache.instance.pack.backPackCache.getEquipItems();
                _loc_9 = [];
                for each (_loc_10 in _loc_8)
                {
                    
                    if (_loc_10 && _loc_10.itemInfo.level <= _loc_3 && _loc_10.itemInfo.type == _loc_4 && _loc_10.itemInfo.career == _loc_6)
                    {
                        _loc_11 = new TransferPackData();
                        _loc_11.itemData = _loc_10;
                        if (this._targetEquip.itemData && this._targetEquip.itemData == _loc_10)
                        {
                            _loc_11.isCurrSelData = true;
                        }
                        else
                        {
                            _loc_11.isCurrSelData = false;
                        }
                        _loc_9.push(_loc_11);
                    }
                }
                if (_loc_7 < 40)
                {
                    return _loc_9;
                }
                if (_loc_5 == ForgingConst.EquipColor_Lv)
                {
                    for each (_loc_12 in _loc_9)
                    {
                        
                        if (_loc_12.itemData.itemInfo.color >= ForgingConst.EquipColor_Lan && EquipmentUtil.compareStrengLevel(_loc_2, _loc_12.itemData) > 0)
                        {
                            _loc_1.push(_loc_12);
                        }
                    }
                }
                if (_loc_5 == ForgingConst.EquipColor_Lan)
                {
                    for each (_loc_12 in _loc_9)
                    {
                        
                        if (_loc_12.itemData.itemInfo.color >= ForgingConst.EquipColor_Zi)
                        {
                            if (EquipmentUtil.compareStrengLevel(_loc_2, _loc_12.itemData) >= 0)
                            {
                                _loc_1.push(_loc_12);
                            }
                            continue;
                        }
                        if (_loc_12.itemData.itemInfo.color == ForgingConst.EquipColor_Lv)
                        {
                            if (EquipmentUtil.compareStrengLevel(_loc_2, _loc_12.itemData) < 0)
                            {
                                _loc_1.push(_loc_12);
                            }
                            continue;
                        }
                        if (_loc_12.itemData.itemInfo.color == ForgingConst.EquipColor_Lan)
                        {
                            if (EquipmentUtil.compareStrengLevel(_loc_2, _loc_12.itemData) < 0 || _loc_2.itemInfo.level < _loc_12.itemData.itemInfo.level)
                            {
                                _loc_1.push(_loc_12);
                            }
                        }
                    }
                }
                if (_loc_5 >= ForgingConst.EquipColor_Zi)
                {
                    for each (_loc_12 in _loc_9)
                    {
                        
                        if (_loc_12.itemData.itemInfo.color >= ForgingConst.EquipColor_Zi || _loc_12.itemData.itemInfo.color < ForgingConst.EquipColor_Zi && EquipmentUtil.compareStrengLevel(_loc_2, _loc_12.itemData) < 0)
                        {
                            _loc_1.push(_loc_12);
                        }
                    }
                }
            }
            return _loc_1;
        }// end function

        private function onTransformHandler(event:MouseEvent) : void
        {
            var data:Object;
            var transFromData:ItemData;
            var transToData:ItemData;
            var equipName:String;
            var desc:String;
            var e:* = event;
            if (!_currOperEquip.itemData || !this._targetEquip.itemData)
            {
                MsgManager.showRollTipsMsg(Language.getString(41138));
                return;
            }
            if (_currOperEquip.itemData && this._targetEquip.itemData)
            {
                data;
                if (this._isLeftToRight)
                {
                    transFromData = _currOperEquip.itemData;
                    transToData = this._targetEquip.itemData;
                }
                else
                {
                    transFromData = this._targetEquip.itemData;
                    transToData = _currOperEquip.itemData;
                }
                data["fromUid"] = transFromData.uid;
                data["toUid"] = transToData.uid;
                data["fromPosType"] = transFromData.posType;
                data["toPosType"] = transToData.posType;
                if (transToData.extInfo.bd == EBind._EBindAfterUse)
                {
                    var onEquip:* = function (param1:int) : void
            {
                if (param1 == Alert.OK)
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.EquipTransform, data));
                }
                return;
            }// end function
            ;
                    if (AutoGuideCache.isGuidingEquipTransform)
                    {
                        this.onEquip(Alert.OK);
                    }
                    else
                    {
                        equipName = transToData.itemInfo.name;
                        desc = Language.getString(41139);
                        Alert.show(desc, null, Alert.OK | Alert.CANCEL, null, onEquip);
                    }
                }
                else
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.EquipTransform, data));
                }
            }
            return;
        }// end function

        private function set isTransAvailabel(param1:Boolean) : void
        {
            if (param1)
            {
                this._transformBtn.mouseEnabled = true;
                this._transformBtn.filters = [];
            }
            else
            {
                this._transformBtn.mouseEnabled = false;
                this._transformBtn.filters = [FilterConst.colorFilter2];
            }
            return;
        }// end function

        private function onTransferSuccClear() : void
        {
            if (this._transToEquip.itemData == _currOperEquip.itemData)
            {
                this._reviewText1.visible = true;
                this._fromEquipCombat.text = "";
            }
            else
            {
                this._reviewText2.visible = true;
                this._toEquipCombat.text = "";
            }
            this._transToEquip.itemData = null;
            this.isTransAvailabel = false;
            this._upFee.text = "";
            this._transToEquip.updateStrengLevel();
            return;
        }// end function

        override protected function onEquipClickHandler(event:MouseEvent) : void
        {
            super.onEquipClickHandler(event);
            this._addEquip = null;
            if (!this._backPackPanel.isHide)
            {
                this._backPackPanel.hide();
            }
            return;
        }// end function

        private function onTargetEquipClickHandler(event:MouseEvent) : void
        {
            var _loc_2:* = event.target as PlayerEquipItem;
            if (_loc_2.itemData)
            {
                this.onTargetCancelClear();
                Dispatcher.dispatchEvent(new DataEvent(EventName.ForgingResetTransferPack));
            }
            return;
        }// end function

        private function playTransferEffect() : void
        {
            var _loc_1:* = (_window as ForgingModule).rect3d;
            if (_loc_1)
            {
                _loc_1.disposeObj3d(this._effectPlayer);
                this._effectPlayer = EffectPlayerPool.instance.getEffectPlayer("ZS-jiasu", null, _loc_1.renderList, false);
                this._effectPlayer.setScale(0.4, 0.4, 0.4);
                this._effectPlayer.play(PlayMode.ANIMATION_STOP_MODE);
                FrEventDispatcher.instance.proxyAddEventListener(this._effectPlayer, Engine3dEventName.PLAYEND, this.playEndHander);
                _loc_1.addObject3d(this._effectPlayer, 180 + 67, 210 - 8 - 34 + 180);
            }
            return;
        }// end function

        private function playEndHander(event:Event) : void
        {
            var _loc_2:* = event.currentTarget as EffectPlayer;
            var _loc_3:* = (_window as ForgingModule).rect3d;
            if (_loc_3)
            {
                _loc_3.disposeObj3d(_loc_2);
            }
            return;
        }// end function

        private function onTargetCancelClear() : void
        {
            this._targetEquip.itemData = null;
            this._reviewEquip.itemData = null;
            this._toEquipCombat.text = "";
            this._reviewCombat.text = "";
            this._upFee.text = "";
            this._combatUpValue.text = "";
            this._upArrow.visible = false;
            this.isTransAvailabel = false;
            this._reviewText2.visible = true;
            this._reviewText3.visible = true;
            this._targetEquip.updateStrengLevel();
            this._reviewEquip.updateStrengLevel();
            if (!_currOperEquip.itemData)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.ResetCurrSelEquip));
            }
            return;
        }// end function

        override public function clearUI() : void
        {
            super.clearUI();
            this._fromEquipCombat.text = "";
            this._toEquipCombat.text = "";
            this._reviewCombat.text = "";
            this._combatUpValue.text = "";
            this._upArrow.visible = false;
            this._reviewText1.visible = true;
            this._reviewText2.visible = true;
            this._reviewText3.visible = true;
            this._upFee.text = "";
            this.isTransAvailabel = false;
            this._targetEquip.itemData = null;
            this._reviewEquip.itemData = null;
            this._gemHoleArr.length = 0;
            this._targetEquip.updateStrengLevel();
            this._reviewEquip.updateStrengLevel();
            this._transferLeftArrow.visible = false;
            this._transferRightArrow.visible = true;
            return;
        }// end function

        private function remove3D() : void
        {
            var _loc_1:* = (_window as ForgingModule).rect3d;
            if (this._effectPlayer)
            {
                _loc_1.disposeObj3d(this._effectPlayer);
                this._effectPlayer = null;
            }
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            if (_isCreateChildren)
            {
                _isCreateChildren = false;
                this._transformBtn.name = "";
                this._fromEquipCombat.dispose(param1);
                this._toEquipCombat.dispose(param1);
                this._reviewCombat.dispose(param1);
                this._combatUpValue.dispose(param1);
                this._upArrow.dispose(param1);
                this._selBagText.dispose(param1);
                this._transformBtn.dispose(param1);
                this._upFee.dispose(param1);
                _currOperEquip.dispose(param1);
                this._targetEquip.dispose(param1);
                this._reviewEquip.dispose(param1);
                this._reviewText1.dispose(param1);
                this._reviewText2.dispose(param1);
                this._reviewText3.dispose(param1);
                this._backPackPanel.dispose(param1);
                this._explainText.dispose(param1);
                this._transferLeftArrow.dispose(param1);
                this._transferRightArrow.dispose(param1);
                this._fromEquipCombat = null;
                this._toEquipCombat = null;
                _currOperEquip = null;
                this._reviewCombat = null;
                this._combatUpValue = null;
                this._upArrow = null;
                this._selBagText = null;
                this._transformBtn = null;
                this._upFee = null;
                this._targetEquip = null;
                this._targetEquip = null;
                this._reviewText1 = null;
                this._reviewText2 = null;
                this._reviewText3 = null;
                this._backPackPanel = null;
                this._explainText = null;
                this._transFromEquip = null;
                this._transToEquip = null;
                this._transferLeftArrow = null;
                this._transferRightArrow = null;
            }
            this._gemHoleArr.length = 0;
            this._isLeftToRight = false;
            this._addEquip = null;
            Dispatcher.removeEventListener(EventName.AddTargetEquip, this.addTargetEquip);
            NetDispatcher.removeCmdListener(ServerCommand.EquipTransferInfoUpdate, this.onEquipTransferSucc);
            this.remove3D();
            return;
        }// end function

    }
}
